<style type="text/css">
.layui-table-cell, .layui-table td, .layui-table th {
	overflow: inherit;
	line-height:22px;
	padding:2px 5px;
}
.layui-input, .layui-select, .layui-textarea{height:28px;}
</style>
<div class="layui-table-tool" style="padding:6px 0px;min-height:inherit;">
  <div class="layui-table-tool-temp" style="padding:0px 6px;"> <span> &nbsp;&nbsp;说明-&gt; 比例为0则关闭不分配对应订单 </span> </div>
</div>
<form class="layui-form" action="{:url()}" method="post" id="editForm">
  <table class="layui-table">
    <thead>
      <tr>
        <th style="text-align:center">工厂</th>
        <th>小辉辉针织 <br />
          分配百分比</th>
        <th>名贵坊针织 <br />
          分配百分比</th>
        <th>小辉辉梭织 <br />
          分配百分比</th>
        <th>名贵坊梭织 <br />
          分配百分比</th>
        <th>十义针织 <br />
      	  分配百分比</th>
        <th>十义梭织<br />
          分配百分比</th>
        <th>二次工艺<br />
          可接区域</th>
        <th width="60px;">分单状态</th>
      </tr>
    </thead>
    <tbody>    
    {foreach $factoryKV as $factoryId=>$factoryName}
    <tr>
      <td width="100px">{$factoryName}</td>
      <td><input type="text" name="knit_one_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'knit_one_per', 0)}" placeholder="" class="layui-input"></td>
      <td><input type="text" name="knit_two_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'knit_two_per', 0)}" placeholder="" class="layui-input"></td>
      <td><input type="text" name="tat_one_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'tat_one_per', 0)}" placeholder="" class="layui-input" /></td>
      <td><input type="text" name="tat_two_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'tat_two_per', 0)}" placeholder="" class="layui-input" /></td>
      <td><input type="text" name="knit_thr_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'knit_thr_per', 0)}" placeholder="" class="layui-input"></td>
      <td><input type="text" name="tat_thr_per[{$factoryId}]"  autocomplete="off" value="{:arrayGet(arrayGet($list, $factoryId, []), 'tat_thr_per', 0)}" placeholder="" class="layui-input" /></td>
      <td><select name="fabric_process_addr[{$factoryId}]" onchange="setProcessName(this)" lay-ignore="">
          <option value="0">广州与江西</option>
          <option value="1" {if (arrayGet(arrayGet($list, $factoryId, []), 'fabric_process_addr')==1)}selected=""{/if}>江西</option>
        </select></td>
      <td><input type="checkbox" name="status[{$factoryId}]" lay-skin="switch" lay-text="开|关" {if (arrayGet(arrayGet($list, $factoryId, []), 'status')==1)}checked=""{/if}></td>
    </tr>
    {/foreach}
    <tr>
      <td>总比例：</td>
      <td>{:array_sum(array_column($list,'knit_one_per'))}%</td>
      <td>{:array_sum(array_column($list,'knit_two_per'))}%</td>
      <td>{:array_sum(array_column($list,'tat_one_per'))}%</td>
      <td>{:array_sum(array_column($list,'tat_two_per'))}%</td>
      <td>{:array_sum(array_column($list,'knit_thr_per'))}%</td>
      <td>{:array_sum(array_column($list,'tat_thr_per'))}%</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    </tbody>
  </table>
  <div class="pop-bottom-bar">
    <input type="hidden" class="field-id" name="id">
    <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: false, refresh: false,callback: callbackUpdateTask}">提交保存</button>
    <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a> </div>
</form>
{include file="system@block/layui" /}
<script>
	layui.use(['form'], function() {
		var $ = layui.jquery, form = layui.form;
	});
	//callback: callbackUpdateTask
	window.callbackUpdateTask = function(obj, res) {
		if (res.code == 1){
			layer.msg(res.msg, {icon: 1,time:600,end:function(){
				parent.layui.layer.closeAll();
				parent.location.reload();
			}});
		}else{
            layer.msg(res.msg,{icon: 2,time:4000});
		}
	}

</script>
